'use strict'

import { DataTypes, Model, Op } from 'sequelize';
import { db_conf } from '../../config/config.mysql';
import { userModelData } from '../modData/dataList';
import dbInstance from '../../lib/db/mysql'
const seq = dbInstance.getSequelizeInstance(db_conf);
class UserMod extends Model { }

UserMod.init(
    userModelData,
    {
        freezeTableName: true,
        sequelize: seq,
        modelName: 'users',
        timestamps: false
    }
)

// get userInfo by name
export async function getUserInfo(usernName: string): Promise<UserMod | null> {
    return await UserMod.findOne({
        where: {
            name: usernName
        }
    })
}